RetryBudget

JS/TS-friendly facade over com.sorinirmies.arrow.resiliencekit.RetryBudget / retryWithBudget -- a system-wide guard against retry storms, shared across every call site retrying against a given downstream.

import { RetryBudget } from "arrow-resilience-kit";

const budget = await RetryBudget.create(); // one instance per downstream, shared across call sites
const result = await budget.retry(() => callFlakyService(), 5);

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard

Current token balance.

Link copied to clipboard

Records a successful, non-retry call, depositing a token (capped at maxTokens).

Link copied to clipboard
fun <T> retry(block: () -> Promise<T>, retries: Int = 3, initialDelayMillis: Double = 100.0, maxDelayMillis: Double, factor: Double = 2.0): Promise<T>

Retries block with exponential backoff, gated by this budget -- see com.sorinirmies.arrow.resiliencekit.RetryBudget for why. Rejects with an error whose message starts with "Retry budget exhausted" if the budget runs out before retries does (distinct from the original failure's error, which is what every other exhaustion rejects with).

Link copied to clipboard

Attempts to withdraw one retry token directly; resolves true if one was available.